const Controller = require('../../core/controller/ApiController');
const {Route, HttpGet, Middleware, filters} = require('../../../plugin/egg-decorator-router/lib');
const {ExceptionHandler} = require('../../../plugin/egg-controller-exception-handler/lib');

@Route('/api/admin')
class CommonCtrl extends Controller {

    //获取社区列表
    @HttpGet('/community/list')
    @ExceptionHandler()
    async getCommunityList() {
        this.result.data = await this.service.admin.common.main.getCommunityList();
        return '查询成功'
    }

    //获取小区列表
    @HttpGet('/sudistrict/list')
    @ExceptionHandler()
    async getSubistrictList() {
        const rule = {
            community_id: 'int'
        };
        this.validate(rule, this.ctx.request.query);
        this.result.data = await this.service.admin.common.main.getSubistrictList(this.ctx.request.query.community_id);
        return '查询成功'
    }
}

module.exports = CommonCtrl;
